/*
 * 类名称:PlatformDetailController.java
 * 包名称:com.platform.controller
 *
 * 修改履历:
 *     日期                       修正者        主要内容
 *     2019-09-24 23:54:59        lipengjun     初版做成
 *
 * Copyright (c) 2019-2019 微同科技
 */
package com.platform.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.platform.annotation.SysLog;
import com.platform.entity.PlatformDetailEntity;
import com.platform.utils.PageUtils;
import com.platform.utils.R;
import com.platform.service.PlatformDetailService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 平台详情表Controller
 *
 * @author lipengjun
 * @date 2019-09-24 23:54:59
 */
@RestController
@RequestMapping("platformdetail")
public class PlatformDetailController extends AbstractController {
    @Autowired
    private PlatformDetailService platformDetailService;

    /**
     * 查看所有列表
     *
     * @param params 查询参数
     * @return R
     */
    @RequestMapping("/queryAll")
    @RequiresPermissions("platformdetail:list")
    public R queryAll(@RequestParam Map<String, Object> params) {
        List<PlatformDetailEntity> list = platformDetailService.queryAll(params);

        return R.ok().put("list", list);
    }

    /**
     * 分页查询平台详情表
     *
     * @param params 查询参数
     * @return R
     */
    @GetMapping("/list")
    @RequiresPermissions("platformdetail:list")
    public R list(@RequestParam Map<String, Object> params) {
        Page page = platformDetailService.queryPage(params);
        PageUtils pages = new PageUtils(page.getRecords(),
                Integer.parseInt(String.valueOf(page.getTotal())),
                Integer.parseInt(String.valueOf(page.getSize())),
                Integer.parseInt(String.valueOf(page.getCurrent())));
        return R.ok().put("page", pages);
    }

    /**
     * 根据主键查询详情
     *
     * @param id 主键
     * @return R
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("platformdetail:info")
    public R info(@PathVariable("id") Integer id) {
        PlatformDetailEntity platformDetail = platformDetailService.getById(id);

        return R.ok().put("platformdetail", platformDetail);
    }

    /**
     * 新增平台详情表
     *
     * @param platformDetail platformDetail
     * @return R
     */
    @SysLog("新增平台详情表")
    @RequestMapping("/save")
    @RequiresPermissions("platformdetail:save")
    public R save(@RequestBody PlatformDetailEntity platformDetail) {

        platformDetailService.add(platformDetail);

        return R.ok();
    }

    /**
     * 修改平台详情表
     *
     * @param platformDetail platformDetail
     * @return R
     */
    @SysLog("修改平台详情表")
    @RequestMapping("/update")
    @RequiresPermissions("platformdetail:update")
    public R update(@RequestBody PlatformDetailEntity platformDetail) {

        platformDetailService.update(platformDetail);

        return R.ok();
    }

    /**
     * 根据主键删除平台详情表
     *
     * @param ids ids
     * @return R
     */
    @SysLog("删除平台详情表")
    @RequestMapping("/delete")
    @RequiresPermissions("platformdetail:delete")
    public R delete(@RequestBody Integer[] ids) {
        platformDetailService.deleteBatch(ids);

        return R.ok();
    }
}
